
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="订单编号" prop="orderCode">
        <el-input v-model="queryParams.orderCode" placeholder="请输入订单编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="规格" prop="specification">
        <el-input v-model="queryParams.specification" placeholder="请输入订单编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="产品" prop="productName">
        <el-input v-model="queryParams.productName" placeholder="请输入订单编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    
    <el-tabs v-model="activeName" >
      <el-tab-pane label="订单计划成本" name="first">
        <h2 align="center">订单计划成本</h2>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" size="mini" @click="handleAddOrderPlanCost">新增</el-button>
          </el-col>
        </el-row>
        <el-tooltip placement="top">
          <div slot="content">点击任意一行列，即可在下方查看订单计划成本详情记录</div>
        <el-table :data="orderPlanTableData"  v-loading="loading" @row-click="showTab" >
          <el-table-column align="center" label="订单编号" prop="orderCode" />
          <el-table-column align="center" label="日期" prop="date"  />
          <el-table-column align="center" label="产品" prop="productName" />
          <el-table-column align="center" label="规格" prop="specification" />
          <el-table-column align="center" label="装箱数" prop="boxNum" />
          <el-table-column align="center" label="财务费用" prop="financeAmount" />
          <el-table-column align="center" label="管理分摊" prop="manageAmount" />
          <el-table-column align="center" label="开发费用" prop="developAmount" />
          <el-table-column align="center" label="运输费用" prop="transportAmount" />
          <el-table-column align="center" label="其他费用" prop="otherAmount" />
          <el-table-column align="center" label="税收费用" prop="taxAmount" />
          <el-table-column align="center" label="制造成本" prop="manufactureCost" />
          <el-table-column align="center" label="成本合计" prop="totalCost" />
          <el-table-column align="center" label="销售金额" prop="saleAmount" />
          <el-table-column align="center" label="利润率" prop="profitRate" />
          <el-table-column align="center" label="单个成本" prop="singleCost" />
          <el-table-column align="center" label="单个报价" prop="unitPrice" />
          <el-table-column align="center" label="订单数量" prop="orderNum" />
          <el-table-column align="center" label="合同号" prop="contractNum" />
          <el-table-column align="center" label="备注" prop="remark" />
          <el-table-column align="center" fixed="right" label="操作" width="150">
            <template slot-scope="scope">
              <el-button type="text" size="mini" @click="handleUpdateOrderPlanCost(scope.row)">修改</el-button>
              <el-button type="text" size="mini" @click="handleDeleteOrderPlanCost(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        </el-tooltip>
        
        <pagination  :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
        
        <el-tabs v-model="activeName2" v-if="showTable">
          <h2 align="center">{{orderCode}}订单计划成本详情</h2>
          <el-tab-pane label="注塑费用" name="first" v-loading="loadinginjectionMolding">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddInjectionMolding">新增</el-button>
              </el-col>
            </el-row>
            <el-table :data="injectTableData" >
              <el-table-column align="center" label="零件代号" prop="partCode" />
              <el-table-column align="center" label="零件名称" prop="partName" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="工模编号" prop="modelCode" />
              <el-table-column align="center" label="工模名称" prop="modelName" />
              <el-table-column align="center" label="出数" prop="outNum" />
              <el-table-column align="center" label="机型" prop="machineType" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="每个加工费" prop="cost" />
              <el-table-column align="center" label="总加工费" prop="totalCost" />
              <el-table-column align="center" label="注塑单价" prop="unitPrice" />
              <el-table-column align="center" label="计件工资" prop="wage" />
              <el-table-column align="center" label="计时单价" prop="timePrice" />
              <el-table-column align="center" label="计时工资" prop="timeWage" />
              <el-table-column align="center" label="工资总额" prop="totalWage" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateInjectionMolding(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteInjectionMolding(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="辅料价格" name="second" v-loading="loadingAccessoriesPrice">
             <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddAuxiliaryPrice">新增</el-button>
              </el-col>
             </el-row>
            <el-table :data="accessoriesPriceTableData" >
              <el-table-column align="center" label="代号" prop="accessoriesCode" />
              <el-table-column align="center" label="名称" prop="accessoriesName" />
              <el-table-column align="center" label="规格" prop="specification" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="属性" prop="attribute" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="单价" prop="unitPrice" />
              <el-table-column align="center" label="费用" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateAuxiliaryPrice(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteAuxiliaryPrice(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="原料价格" name="third" v-loading="loadingMaterialPrice">
             <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddMaterialPrice">新增</el-button>
              </el-col>
             </el-row>
            <el-table :data="materialPriceTableData" >
              <el-table-column align="center" label="代号" prop="materialCode" />
              <el-table-column align="center" label="名称" prop="materialName" />
              <el-table-column align="center" label="规格" prop="specification" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="单价" prop="unitPrice" />
              <el-table-column align="center" label="费用" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateMaterialPrice(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteMaterialPrice(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="加工费用" name="fourth" v-loading="loadingProcessCost">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddProcessCost">新增</el-button>
              </el-col>
            </el-row>
            <el-table :data="processCostTableData" >
              <el-table-column align="center" label="代号" prop="processCode" />
              <el-table-column align="center" label="名称" prop="processName" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="加工工序" prop="process" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="加工单价" prop="unitPrice" />
              <el-table-column align="center" label="加工金额" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateProcessCost(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteProcessCost(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="二次加工费用" name="fifth" v-loading="loadingSecondProcessCost">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddSecondProcessCost">新增</el-button>
              </el-col>
            </el-row>
            <el-table :data="secondProcessCostTableData">
              <el-table-column align="center" label="代号" prop="secondProcessCode" />
              <el-table-column align="center" label="名称" prop="secondProcessName" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="加工工序" prop="secondProcess" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="加工单价" prop="unitPrice" />
              <el-table-column align="center" label="加工金额" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateSecondProcessCost(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteSecondProcessCost(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
        
      </el-tab-pane>
      <el-tab-pane label="订单实际成本" name="second">
        <h2 align="center">订单实际成本</h2>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" size="mini" @click="handleAddOrderPlanCost1">新增</el-button>
          </el-col>
        </el-row>
        <el-tooltip placement="top">
          <div slot="content">点击任意一行列即可查看该订单的详细信息</div>
        <el-table :data="orderPlanTableData" @row-click="showTab" >
          <el-table-column align="center" label="订单编号" prop="orderCode" />
          <el-table-column align="center" label="日期" prop="date"  />
          <el-table-column align="center" label="产品" prop="productName" />
          <el-table-column align="center" label="规格" prop="specification" />
          <el-table-column align="center" label="装箱数" prop="boxNum" />
          <el-table-column align="center" label="财务费用" prop="financeAmount" />
          <el-table-column align="center" label="管理分摊" prop="manageAmount" />
          <el-table-column align="center" label="开发费用" prop="developAmount" />
          <el-table-column align="center" label="运输费用" prop="transportAmount" />
          <el-table-column align="center" label="其他费用" prop="otherAmount" />
          <el-table-column align="center" label="税收费用" prop="taxAmount" />
          <el-table-column align="center" label="制造成本" prop="manufactureCost" />
          <el-table-column align="center" label="成本合计" prop="totalCost" />
          <el-table-column align="center" label="销售金额" prop="saleAmount" />
          <el-table-column align="center" label="利润率" prop="profitRate" />
          <el-table-column align="center" label="单个成本" prop="singleCost" />
          <el-table-column align="center" label="单个报价" prop="unitPrice" />
          <el-table-column align="center" label="订单数量" prop="orderNum" />
          <el-table-column align="center" label="合同号" prop="contractNum" />
          <el-table-column align="center" label="备注" prop="remark" />
          <el-table-column align="center" fixed="right" label="操作" width="150">
            <template slot-scope="scope">
              <el-button type="text" size="mini" @click="handleUpdateOrderPlanCost1(scope.row)">修改</el-button>
              <el-button type="text" size="mini" @click="handleDeleteOrderPlanCost1(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        </el-tooltip>
        
        <pagination  :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
        
        <el-tabs v-model="activeName1" v-if="showTable">
          <h2 align="center">{{orderCode}}订单实际成本详情</h2>
          <el-tab-pane label="注塑费用" name="first" v-loading="loadinginjectionMolding">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddInjectionMolding">新增</el-button>
              </el-col>
            </el-row>
            <el-table :data="injectTableData" >
              <el-table-column align="center" label="零件代号" prop="partCode" />
              <el-table-column align="center" label="零件名称" prop="partName" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="工模编号" prop="modelCode" />
              <el-table-column align="center" label="工模名称" prop="modelName" />
              <el-table-column align="center" label="出数" prop="outNum" />
              <el-table-column align="center" label="机型" prop="machineType" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="每个加工费" prop="cost" />
              <el-table-column align="center" label="总加工费" prop="totalCost" />
              <el-table-column align="center" label="注塑单价" prop="unitPrice" />
              <el-table-column align="center" label="计件工资" prop="wage" />
              <el-table-column align="center" label="计时单价" prop="timePrice" />
              <el-table-column align="center" label="计时工资" prop="timeWage" />
              <el-table-column align="center" label="工资总额" prop="totalWage" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateInjectionMolding(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteInjectionMolding(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="辅料价格" name="second" v-loading="loadingAccessoriesPrice">
             <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddAuxiliaryPrice">新增</el-button>
              </el-col>
             </el-row>
            <el-table :data="accessoriesPriceTableData" >
              <el-table-column align="center" label="代号" prop="accessoriesCode" />
              <el-table-column align="center" label="名称" prop="accessoriesName" />
              <el-table-column align="center" label="规格" prop="specification" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="属性" prop="attribute" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="单价" prop="unitPrice" />
              <el-table-column align="center" label="费用" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateAuxiliaryPrice(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteAuxiliaryPrice(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="原料价格" name="third" v-loading="loadingMaterialPrice">
             <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddMaterialPrice">新增</el-button>
              </el-col>
             </el-row>
            <el-table :data="materialPriceTableData" >
              <el-table-column align="center" label="代号" prop="materialCode" />
              <el-table-column align="center" label="名称" prop="materialName" />
              <el-table-column align="center" label="规格" prop="specification" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="单价" prop="unitPrice" />
              <el-table-column align="center" label="费用" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateMaterialPrice(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteMaterialPrice(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="加工费用" name="fourth" v-loading="loadingProcessCost">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddProcessCost">新增</el-button>
              </el-col>
            </el-row>
            <el-table :data="processCostTableData" >
              <el-table-column align="center" label="代号" prop="processCode" />
              <el-table-column align="center" label="名称" prop="processName" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="加工工序" prop="process" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="加工单价" prop="unitPrice" />
              <el-table-column align="center" label="加工金额" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateProcessCost(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteProcessCost(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="二次加工费用" name="fifth" v-loading="loadingSecondProcessCost">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" size="mini" @click="handleAddSecondProcessCost">新增</el-button>
              </el-col>
            </el-row>
            <el-table :data="secondProcessCostTableData">
              <el-table-column align="center" label="代号" prop="secondProcessCode" />
              <el-table-column align="center" label="名称" prop="secondProcessName" />
              <el-table-column align="center" label="单位" prop="unit" />
              <el-table-column align="center" label="加工工序" prop="secondProcess" />
              <el-table-column align="center" label="用量" prop="useNum" />
              <el-table-column align="center" label="数量" prop="num" />
              <el-table-column align="center" label="加工单价" prop="unitPrice" />
              <el-table-column align="center" label="加工金额" prop="cost" />
              <el-table-column align="center" label="操作" width="150" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="handleUpdateSecondProcessCost(scope.row)">修改</el-button>
                  <el-button type="text" size="mini" @click="handleDeleteSecondProcessCost(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
        
      </el-tab-pane>
    </el-tabs>
    
    <!-- 订单计划成本 -->
    <el-dialog :title="titleOrder" :visible.sync="openOrder" width="800px" append-to-body>
      <el-form :model="orderForm" ref="orderForm" label-width="100px">
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="订单编号" prop="orderCode">
              <el-input v-model="orderForm.orderCode"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日期" prop="date">
              <el-date-picker value-format="yyyy-MM-dd" v-model="orderForm.date" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品" prop="productName">
              <el-input v-model="orderForm.productName"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格" prop="specification">
              <el-input v-model="orderForm.specification"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="装箱数" prop="boxNum">
              <el-input v-model="orderForm.boxNum"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="财务费用" prop="financeAmount">
              <el-input v-model="orderForm.financeAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="管理分摊" prop="manageAmount">
              <el-input v-model="orderForm.manageAmount"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开发费用" prop="developAmount">
              <el-input v-model="orderForm.developAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="运输费用" prop="transportAmount">
              <el-input v-model="orderForm.transportAmount"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="其他费用" prop="otherAmount">
              <el-input v-model="orderForm.otherAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="税收费用" prop="taxAmount">
              <el-input v-model="orderForm.taxAmount"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造成本" prop="manufactureCost">
              <el-input v-model="orderForm.manufactureCost"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="成本合计" prop="totalCost">
              <el-input v-model="orderForm.totalCost"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="销售金额" prop="saleAmount">
              <el-input v-model="orderForm.saleAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="利润率" prop="profitRate">
              <el-input v-model="orderForm.profitRate"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单个成本" prop="singleCost">
              <el-input v-model="orderForm.singleCost"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="单个报价" prop="unitPrice">
              <el-input v-model="orderForm.unitPrice"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单数量" prop="orderNum">
              <el-input v-model="orderForm.orderNum"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="合同号" prop="contractNum">
              <el-input v-model="orderForm.contractNum"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" v-model="orderForm.remark"  />
        </el-form-item>
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    
    <!-- 订单实际成本 -->
    <!-- <el-dialog :title="titleActualCost" :visible.sync="openActualCost" width="500px" append-to-body>
      <el-form :model="actualCostForm" ref="actualCostForm" label-width="100px">
          
        <el-row>
          <el-col :span="12">
            <el-form-item label="订单编号" prop="orderCode">
              <el-input v-model="actualCostForm.orderCode"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日期" prop="date">
              <el-date-picker v-model="actualCostForm.date" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品" prop="productName">
              <el-input v-model="actualCostForm.productName"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格" prop="specification">
              <el-input v-model="actualCostForm.specification"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="装箱数" prop="boxNum">
              <el-input v-model="actualCostForm.boxNum"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="财务费用" prop="financeAmount">
              <el-input v-model="actualCostForm.financeAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="管理分摊" prop="manageAmount">
              <el-input v-model="actualCostForm.manageAmount"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开发费用" prop="developAmount">
              <el-input v-model="actualCostForm.developAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="运输费用" prop="transportAmount">
              <el-input v-model="actualCostForm.transportAmount"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="其他费用" prop="otherAmount">
              <el-input v-model="actualCostForm.otherAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="税收费用" prop="taxAmount">
              <el-input v-model="actualCostForm.taxAmount"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造成本" prop="manufactureCost">
              <el-input v-model="actualCostForm.manufactureCost"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="成本合计" prop="totalCost">
              <el-input v-model="actualCostForm.totalCost"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="销售金额" prop="saleAmount">
              <el-input v-model="actualCostForm.saleAmount"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="利润率" prop="profitRate">
              <el-input v-model="actualCostForm.profitRate"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单个成本" prop="singleCost">
              <el-input v-model="actualCostForm.singleCost"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="单个报价" prop="unitPrice">
              <el-input v-model="actualCostForm.unitPrice"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单数量" prop="orderNum">
              <el-input v-model="actualCostForm.orderNum"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="合同号" prop="contractNum">
              <el-input v-model="actualCostForm.contractNum"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" v-model="actualCostForm.remark"  />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormActualCost">确 定</el-button>
        <el-button @click="cancelActualCost">取 消</el-button>
      </div>
    </el-dialog> -->
    
    <!-- 注塑费用 -->
    <el-dialog :title="titleInjectionMolding" :visible.sync="openInjectionMolding" width="800px" append-to-body>
      <el-form :model="injectionMoldingForm" ref="injectionMoldingForm" label-width="100px">
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="零件代号" prop="partCode">
              <el-input v-model="injectionMoldingForm.partCode"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="零件名称" prop="partName">
              <el-input v-model="injectionMoldingForm.partName"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="单位" prop="unit">
              <el-input v-model="injectionMoldingForm.unit"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工模编号" prop="modelCode">
              <el-input v-model="injectionMoldingForm.modelCode"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="工模名称" prop="modelName">
              <el-input v-model="injectionMoldingForm.modelName"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出数" prop="outNum">
              <el-input v-model="injectionMoldingForm.outNum"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="机型" prop="machineType">
              <el-input v-model="injectionMoldingForm.machineType"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用量" prop="useNum">
              <el-input v-model="injectionMoldingForm.useNum"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="数量" prop="num">
              <el-input v-model="injectionMoldingForm.num"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="每个加工费" prop="cost">
              <el-input v-model="injectionMoldingForm.cost"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="总加工费" prop="totalCost">
              <el-input v-model="injectionMoldingForm.totalCost"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="注塑单价" prop="unitPrice">
              <el-input v-model="injectionMoldingForm.unitPrice"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="计件工资" prop="wage">
              <el-input v-model="injectionMoldingForm.wage"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计时单价" prop="timePrice">
              <el-input v-model="injectionMoldingForm.timePrice"  />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="12">
            <el-form-item label="计时工资" prop="timeWage">
              <el-input v-model="injectionMoldingForm.timeWage"  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工资总额" prop="totalWage">
              <el-input v-model="injectionMoldingForm.totalWage"  />
            </el-form-item>
          </el-col>
        </el-row>
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormInjectionMolding">确 定</el-button>
        <el-button @click="cancelInjectionMolding">取 消</el-button>
      </div>
    </el-dialog>
    
    <!-- 辅料价格 -->
     <el-dialog :title="titleAccessoriesPrice" :visible.sync="openAccessoriesPrice" width="500px" append-to-body>
      <el-form :model="accessoriesPriceForm" ref="accessoriesPriceForm" label-width="100px">
        <el-form-item label="代号" prop="accessoriesCode">
          <el-input v-model="accessoriesPriceForm.accessoriesCode"  />
        </el-form-item>
        <el-form-item label="名称" prop=" ">
          <el-input v-model="accessoriesPriceForm.accessoriesName"  />
        </el-form-item>
        <el-form-item label="规格" prop="specification">
          <el-input v-model="accessoriesPriceForm.specification"  />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="accessoriesPriceForm.unit"  />
        </el-form-item>
        <el-form-item label="属性" prop="attribute">
          <el-input v-model="accessoriesPriceForm.attribute"  />
        </el-form-item>
        <el-form-item label="用量" prop="useNum">
          <el-input v-model="accessoriesPriceForm.useNum"  />
        </el-form-item>
        <el-form-item label="数量" prop="num">
          <el-input v-model="accessoriesPriceForm.num"  />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input v-model="accessoriesPriceForm.unitPrice"  />
        </el-form-item>
        <el-form-item label="费用" prop="cost">
          <el-input v-model="accessoriesPriceForm.cost"  />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormAccessoriesPrice">确 定</el-button>
        <el-button @click="cancelAccessoriesPrice">取 消</el-button>
      </div>
     </el-dialog>
     
     <!-- 原料价格 -->
     <el-dialog :title="titleMaterialPrice" :visible.sync="openMaterialPrice" width="500px" append-to-body>
      <el-form :model="materialPriceForm" ref="materialPriceForm" label-width="100px">
        <el-form-item label="代号" prop="materialCode">
          <el-input v-model="materialPriceForm.materialCode"  />
        </el-form-item>
        <el-form-item label="名称" prop="materialName">
          <el-input v-model="materialPriceForm.materialName"  />
        </el-form-item>
        <el-form-item label="规格" prop="specification">
          <el-input v-model="materialPriceForm.specification"  />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="materialPriceForm.unit"  />
        </el-form-item>
        <el-form-item label="用量" prop="useNum">
          <el-input v-model="materialPriceForm.useNum"  />
        </el-form-item>
        <el-form-item label="数量" prop="num">
          <el-input v-model="materialPriceForm.num"  />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input v-model="materialPriceForm.unitPrice"  />
        </el-form-item>
        <el-form-item label="费用" prop="cost">
          <el-input v-model="materialPriceForm.cost"  />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormMaterialPrice">确 定</el-button>
        <el-button @click="cancelMaterialPrice">取 消</el-button>
      </div>
     </el-dialog>
     
     <!-- 加工费用 -->
      <el-dialog :title="titleProcessCost" :visible.sync="openProcessCost" width="500px" append-to-body>
        <el-form :model="processCostForm" ref="processCostForm" label-width="100px">
          <el-form-item label="代号" prop="processCode">
            <el-input v-model="processCostForm.processCode"  />
          </el-form-item>
          <el-form-item label="名称" prop="processName">
            <el-input v-model="processCostForm.processName"  />
          </el-form-item>
          <el-form-item label="单位" prop="unit">
            <el-input v-model="processCostForm.unit"  />
          </el-form-item>
          <el-form-item label="加工工序" prop="process">
            <el-select v-model="processCostForm.process" placeholder="请选择">
              <el-option label="贴条码" value="1"></el-option>
              <el-option label="垫白纸" value="2"></el-option>
              <el-option label="套袋子" value="3"></el-option>
              <el-option label="入中包装" value="4"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="用量" prop="useNum">
            <el-input v-model="processCostForm.useNum"  />
          </el-form-item>
          <el-form-item label="数量" prop="num">
            <el-input v-model="processCostForm.num"  />
          </el-form-item>
          <el-form-item label="加工单价" prop="unitPrice">
            <el-input v-model="processCostForm.unitPrice"  />
          </el-form-item>
          <el-form-item label="加工金额" prop="cost">
            <el-input v-model="processCostForm.cost"  />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitFormProcessCost">确 定</el-button>
          <el-button @click="cancelProcessCost">取 消</el-button>
        </div>
      </el-dialog>
    
      <!-- 二次加工费用 -->
      <el-dialog :title="titleSecondProcessCost" :visible.sync="openSecondProcessCost" width="500px" append-to-body>
        <el-form :model="secondProcessCostForm" ref="secondProcessCostForm" label-width="100px">
          <el-form-item label="代号" prop="secondProcessCode">
            <el-input v-model="secondProcessCostForm.secondProcessCode"  />
          </el-form-item>
          <el-form-item label="名称" prop="secondProcessName">
            <el-input v-model="secondProcessCostForm.secondProcessName"  />
          </el-form-item>
          <el-form-item label="单位" prop="unit">
            <el-input v-model="secondProcessCostForm.unit"  />
          </el-form-item>
          <el-form-item label="加工工序" prop="secondProcess">
            <el-select v-model="secondProcessCostForm.secondProcess" placeholder="请选择">
              <el-option label="贴条码" value="1"></el-option>
              <el-option label="垫白纸" value="2"></el-option>
              <el-option label="套袋子" value="3"></el-option>
              <el-option label="入中包装" value="4"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="用量" prop="useNum">
            <el-input v-model="secondProcessCostForm.useNum"  />
          </el-form-item>
          <el-form-item label="数量" prop="num">
            <el-input v-model="secondProcessCostForm.num"  />
          </el-form-item>
          <el-form-item label="加工单价" prop="unitPrice">
            <el-input v-model="secondProcessCostForm.unitPrice"  />
          </el-form-item>
          <el-form-item label="加工金额" prop="cost">
            <el-input v-model="secondProcessCostForm.cost"  />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitFormSecondProcessCost">确 定</el-button>
          <el-button @click="cancelSecondProcessCost">取 消</el-button>
        </div>
      </el-dialog>
      
  </div>
</template>

<script>

export default {
  name: 'CostOrder',
  data() {
    return {
      // 订单成本
      titleOrder: '',
      openOrder: false,
      orderForm:{},
      
      //注塑
      titleInjectionMolding: '',
      openInjectionMolding: false,
      injectionMoldingForm:{},
      loadinginjectionMolding: false,
      injectTableData:[{
              partCode: '1001',
              partName: '零件1',
              unit: '个', 
              modelCode: '1001',
              modelName: '工模1',
              outNum: 10,
              machineType: '机型1',
              useNum: 10,
              num: 100,
              cost: 10000,
              totalCost: 10000,
              unitPrice: 100,
              wage: 1000,
              timePrice: 100,
              timeWage: 1000,
              totalWage: 11000
      }],
      
      
      //辅料价格
      titleAccessoriesPrice: '',
      openAccessoriesPrice: false,
      accessoriesPriceForm:{},
      loadingAccessoriesPrice: false,
      accessoriesPriceTableData:[
        {
          accessoriesCode: '1001',
          accessoriesName: '辅料1',
          specification: '规格1',
          unit: '个', 
          attribute: '属性1',
          useNum: 10,
          num: 100,
          unitPrice: 100,
          cost: 10000
        }
    ],
      
      
      // // 订单实际成本
      // titleActualCost: '',
      // openActualCost: false,
      // actualCostForm:{},
      
      // 原料价格
      titleMaterialPrice: '',
      openMaterialPrice: false,
      materialPriceForm:{},
      loadingMaterialPrice: false,
      materialPriceTableData:[{
        materialCode: '1001',
        materialName: '原料1',
        specification: '规格1',
        unit: '个',
        useNum: 10,
        num: 100,
        unitPrice: 100,
        cost: 10000
      }],
      
      // 加工费用
      titleProcessCost: '',
      openProcessCost: false,
      processCostForm:{},
      loadingProcessCost: false,
      processCostTableData:[{
            processCode: '1001',
            processName: '加工1',
            unit: '个',
            process: '贴条码',
            useNum: 10,
            num: 100,
            unitPrice: 100,
            cost: 10000
      }],
      
      // 二次加工费用
      titleSecondProcessCost: '',
      openSecondProcessCost: false,
      secondProcessCostForm:{},
      loadingSecondProcessCost: false,
      secondProcessCostTableData:[{
            secondProcessCode: '1001',
            secondProcessName: '加工2',
            unit: '个',
            secondProcess: '贴条码',
            useNum: 10,
            num: 100,
            unitPrice: 100,
            cost: 10000
      }],
      
      activeName: 'first',
      showSearch: true,
      activeName1: 'first',
      activeName2: 'first',
      showTable: true,
      loading: false,
      orderPlanTableData:[
        {
          orderCode: '20220101001',
          date: '2022-01-01',
          productName: '产品1',
          specification: '规格1',
          boxNum: 10,
          financeAmount: 10000,
          manageAmount: 5000,
          developAmount: 1000,
          transportAmount: 500,
          otherAmount: 100,
          taxAmount: 50,          
          manufactureCost: 10000,
          totalCost: 11000,
          saleAmount: 10000,
          profitRate: 10,
          singleCost: 1000,
          unitPrice: 100,
          orderNum: 100,
          contractNum: '合同1',
          remark: '备注1'
        }
      ],
      queryParams:{
        pageNum: 1,
        pageSize: 10,
        orderCode: ''
      },
      total: 1,
      tabsTable:'订单计划成本',
      orderCode: ''
    }
  },
  methods:{
    showTab(row) {
      this.orderCode = row.orderCode
      this.showTable = true;
    },
    handleClick(data){
      this.tabsTable = data.label;
      this.loading = true;
      this.showTable = false;
      setTimeout(() => {
        this.loading = false;
      }, 1000);
    },
    handleQuery() {},
    getList() {},
    resetQuery() {},
    /* 新增订单计划成本 */
    handleAddOrderPlanCost(){
      this.resetOrderForm();
      this.titleOrder = '新增订单计划成本';
      this.openOrder = true;
    },
    /* 新增订单实际成本 */
    handleAddOrderPlanCost1(){
      this.resetOrderForm();
      this.titleOrder = '新增订单实际成本';
      this.openOrder = true;
    },
    /* 修改订单计划成本 */
    handleUpdateOrderPlanCost(row){
      this.orderForm = row;
      this.titleOrder = '修改订单计划成本';
      this.openOrder = true;
    },
    /* 修改订单实际成本 */
    handleUpdateOrderPlanCost1(row){
      this.orderForm = row;
      this.titleOrder = '修改订单实际成本';
      this.openOrder = true;
    },
    /* 删除订单计划成本 */
    handleDeleteOrderPlanCost(row){
      this.$confirm('是否删除这条订单成本？')
      .then(() => {
        this.orderPlanTableData.splice(this.orderPlanTableData.indexOf(row),1);
        this.loading = true;
        setTimeout(() => {
          this.loading = false;
          this.$message.success('删除成功');
        },1000)
      })
     
    },
    /* 删除订单实际成本 */
    handleDeleteOrderPlanCost1(row){
      this.$confirm('是否删除这条订单成本？')
      .then(() => {
        this.orderPlanTableData.splice(this.orderPlanTableData.indexOf(row),1);
        this.loading = true;
        setTimeout(() => {
          this.loading = false;
          this.$message.success('删除成功');
        },1000)
      })
     
    },
    /* 订单成本提交 */
    submitForm(){
       this.$refs["orderForm"].validate((valid) => {
        if(valid){
          this.loading = true;
           if(this.tabsTable == '订单计划成本'){
            if(this.titleOrder == '新增订单计划成本'){
              setTimeout(() => {
                this.loading = false;
                this.$message.success('新增订单计划成本成功');
                this.orderPlanTableData.push(this.orderForm);
              },1000)
              this.openOrder = false;
            }else if(this.titleOrder == '修改订单计划成本'){
              setTimeout(() => {
                this.loading = false;
                this.$message.success('修改订单计划成本成功');
                this.orderPlanTableData.map((item,index) => {
                  if(item.orderCode == this.orderForm.orderCode){
                    this.orderPlanTableData[index] = this.orderForm;
                  }
                })
              },1000)
              this.openOrder = false;
            }
           } else if(this.tabsTable == '订单实际成本'){
            if(this.titleOrder == '新增订单实际成本'){
              setTimeout(() => {
                this.loading = false;
                this.$message.success('新增订单实际成本成功');
                this.orderPlanTableData.push(this.orderForm);
              },1000)
              this.openOrder = false;
            } else if(this.titleOrder == '修改订单实际成本'){
              setTimeout(() => {
                this.loading = false;
                this.$message.success('修改订单实际成本成功');
                this.orderPlanTableData.map((item,index) => {
                  if(item.orderCode == this.orderForm.orderCode){
                    this.orderPlanTableData[index] = this.orderForm;
                  }
                })
              },1000)
              this.openOrder = false;
            }
           }
        }
       })
    },
    // 关闭订单计划成本
    cancel(){
      this.resetOrderForm();
      this.openOrder = false;
    },
    // 重置订单计划成本
    resetOrderForm() {
      this.orderForm = {
        orderCode: '',
        date: '',
        productName: '',
        specification: '',
        boxNum: '',
        financeAmount: '',
        manageAmount: '',
        developAmount: '',
        transportAmount: '',
        otherAmount: '',
        taxAmount: '',
        manufactureCost: '',
        totalCost: '',
        saleAmount: '',
        profitRate: '',
        singleCost: '',
        unitPrice: '',
        orderNum: '',
        contractNum: '',
        remark: ''
      }
    },
     // 新增注塑费用
    handleAddInjectionMolding(){
      this.resetInjectionMoldingForm();
      this.titleInjectionMolding = '新增注塑费用';
      this.openInjectionMolding = true;
    },
    // 修改注塑费用
    handleUpdateInjectionMolding(row){
      this.injectionMoldingForm = row;
      this.titleInjectionMolding = '修改注塑费用';
      this.openInjectionMolding = true;
    },
    // 删除注塑费用
    handleDeleteInjectionMolding(row){
      this.$confirm('是否删除这条注塑费用？')
      .then(() => {
          console.log(this.injectTableData.length);
          this.loadinginjectionMolding = true;
          this.injectTableData.splice(this.injectTableData.indexOf(row),1);
         setTimeout(() => {
          this.loadinginjectionMolding = false;
          this.$message.success('删除成功');
        },1000)
        
      })
    },
    // 注塑费用提交
    submitFormInjectionMolding(){
      this.$refs["injectionMoldingForm"].validate((valid) => {
        if (valid) {
          this.loadinginjectionMolding = true;
          if(this.tabsTable == '订单计划成本'){
            if(this.titleInjectionMolding == '新增注塑费用'){
              setTimeout(() => {
                this.loadinginjectionMolding = false;
                this.$message.success('新增注塑费用成功');
                this.injectTableData.push(this.injectionMoldingForm);
              },1000)
              this.openInjectionMolding = false;
            } else if(this.titleInjectionMolding == '修改注塑费用'){
              setTimeout(() => {
                this.loadinginjectionMolding = false;
                this.$message.success('修改注塑费用成功');
                this.injectTableData.map(item,index => {
                  if(item.partCode == this.injectionMoldingForm.partCode){
                    this.injectTableData[index] = this.injectionMoldingForm
                  }
                })
              },1000)
              this.openInjectionMolding = false;
            }
          } else if(this.tabsTable == '订单实际成本'){
            if(this.titleInjectionMolding == '新增注塑费用'){
              setTimeout(() => {
                this.loadinginjectionMolding = false;
                this.$message.success('新增注塑费用成功');
                this.injectTableData.push(this.injectionMoldingForm);
              },1000)
              this.openInjectionMolding = false;
            } else if(this.titleInjectionMolding == '修改注塑费用'){
              setTimeout(() => {
                this.loadinginjectionMolding = false;
                this.$message.success('修改注塑费用成功');
                this.injectTableData.map(item,index => {
                  if(item.partCode == this.injectionMoldingForm.partCode){
                    this.injectTableData[index] = this.injectionMoldingForm
                  }
                })
              },1000)
              this.openInjectionMolding = false;
            }
          }
        }
      })
      
    },
    // 关闭注塑费用
    cancelInjectionMolding(){
      this.resetInjectionMoldingForm();
      this.openInjectionMolding = false;
    },
    // 重置注塑费用
    resetInjectionMoldingForm() {
      this.injectionMoldingForm = {
        partCode: '',
        partName: '',
        specification: '',
        unit: '',
        useNum: '',
        num: '',
        unitPrice: '',
        cost: ''
      }
    },
    // 新增辅料价格
    handleAddAuxiliaryPrice(){
      this.resetAccessoriesPriceForm();
      this.titleAccessoriesPrice = '新增辅料价格';
      this.openAccessoriesPrice = true;
    },
    // 修改辅料价格
    handleUpdateAuxiliaryPrice(row){
      this.accessoriesPriceForm = row;
      this.titleAccessoriesPrice = '修改辅料价格';
      this.openAccessoriesPrice = true;
    },
    // 删除辅料价格
    handleDeleteAuxiliaryPrice(row){
      this.$confirm('是否删除这条辅料价格？')
      .then(() => {
          this.loadingAccessoriesPrice = true
          this.accessoriesPriceTableData.splice(this.accessoriesPriceTableData.indexOf(row),1)
          setTimeout(() => {
            this.loadingAccessoriesPrice = false;
            this.$message.success('删除成功');
          },1000)
       })
    },
    // 辅料价格提交
    submitFormAccessoriesPrice(){
      this.$refs["accessoriesPriceForm"].validate((valid) => {
        if (valid) {
          this.loadingAccessoriesPrice = true;
          if(this.tabsTable == '订单计划成本'){
            if(this.titleAccessoriesPrice == '新增辅料价格'){
              setTimeout(() => {
                this.loadingAccessoriesPrice = false;
                this.$message.success('新增辅料价格成功');
                this.accessoriesPriceTableData.push(this.accessoriesPriceForm);
              },1000)
              this.openAccessoriesPrice = false;
              console.log(this.accessoriesPriceTableData);
              
            } else if(this.titleAccessoriesPrice == '修改辅料价格'){
              setTimeout(() => {
                this.loadingAccessoriesPrice = false;
                this.$message.success('修改辅料价格成功');
                this.accessoriesPriceTableData.map(item,index => {
                  if(item.partCode == this.accessoriesPriceForm.partCode){
                    this.accessoriesPriceTableData[index] = this.accessoriesPriceForm
                  }
                })
              },1000)
              this.openAccessoriesPrice = false;
            }
          } else if(this.tabsTable == '订单实际成本'){
            if(this.titleAccessoriesPrice == '新增辅料价格'){
              setTimeout(() => {
                this.loadingAccessoriesPrice = false;
                this.$message.success('新增辅料价格成功');
                this.accessoriesPriceTableData.push(this.accessoriesPriceForm);
              },1000)
              this.openAccessoriesPrice = false;
            } else if(this.titleAccessoriesPrice == '修改辅料价格'){
              setTimeout(() => {
                this.loadingAccessoriesPrice = false;
                this.$message.success('修改辅料价格成功');
                this.accessoriesPriceTableData.map(item,index => {
                  if(item.partCode == this.accessoriesPriceForm.partCode){
                    this.accessoriesPriceTableData[index] = this.accessoriesPriceForm
                  }
                })
              },1000)
              this.openAccessoriesPrice = false;
            }
          }
        }
      })
    },
    // 关闭辅料价格
    cancelAccessoriesPrice(){
      this.resetAccessoriesPriceForm();
      this.openAccessoriesPrice = false;
    },
    // 重置辅料价格
    resetAccessoriesPriceForm() {
      this.accessoriesPriceForm = {
        partCode: '',
        partName: '',
        specification: '',
        unit: '',
        useNum: '',
        num: '',
        unitPrice: '',
        cost: ''
      }
    },
    // 新增原料价格
    handleAddMaterialPrice(){
      this.resetMaterialPriceForm();
      this.titleMaterialPrice = '新增原料价格';
      this.openMaterialPrice = true;
    },
    // 修改原料价格
    handleUpdateMaterialPrice(row){
      this.materialPriceForm = row;
      this.titleMaterialPrice = '修改原料价格';
      this.openMaterialPrice = true;
    },
    // 删除原料价格
    handleDeleteMaterialPrice(row){
      this.$confirm('是否删除这条原料价格？')
      .then(() => {
          this.loadingMaterialPrice = true;
          this.materialPriceTableData.splice(this.materialPriceTableData.indexOf(row),1)
          setTimeout(() => {
            this.loadingMaterialPrice = false;
            this.$message.success('删除成功');
          },1000)
        })
    },
    // 原料价格提交
    submitFormMaterialPrice(){
      this.$refs["materialPriceForm"].validate((valid) => {
        if (valid) {
          this.loadingMaterialPrice = true;
          if(this.tabsTable == '订单计划成本'){
            if(this.titleMaterialPrice == '新增原料价格'){
              setTimeout(() => {
                this.loadingMaterialPrice = false;
                this.$message.success('新增原料价格成功');
                this.materialPriceTableData.push(this.materialPriceForm);
              },1000)
              this.openMaterialPrice = false;
            } else if(this.titleMaterialPrice == '修改原料价格'){
              setTimeout(() => {
                this.loadingMaterialPrice = false;
                this.$message.success('修改原料价格成功');
                this.materialPriceTableData.map(item,index => {
                  if(item.partCode == this.materialPriceForm.partCode){
                    this.materialPriceTableData[index] = this.materialPriceForm
                  }
                })
              },1000)
              this.openMaterialPrice = false;
            }
          } else if(this.tabsTable == '订单实际成本'){
            if(this.titleMaterialPrice == '新增原料价格'){
              setTimeout(() => {
                this.loadingMaterialPrice = false;
                this.$message.success('新增原料价格成功');
                this.materialPriceTableData.push(this.materialPriceForm);
              },1000)
              this.openMaterialPrice = false;
            } else if(this.titleMaterialPrice == '修改原料价格'){
              setTimeout(() => {
                this.loadingMaterialPrice = false;
                this.$message.success('修改原料价格成功');
                this.materialPriceTableData.map(item,index => {
                  if(item.partCode == this.materialPriceForm.partCode){
                    this.materialPriceTableData[index] = this.materialPriceForm
                  }
                })
              },1000)
              this.openMaterialPrice = false;
            }
          }
        }
      })
    },
    // 关闭原料价格
    cancelMaterialPrice(){
      this.resetMaterialPriceForm();
      this.openMaterialPrice = false;
    },
    // 重置原料价格
    resetMaterialPriceForm() {
      this.materialPriceForm = {
        partCode: '',
        partName: '',
        specification: '',
        unit: '',
        useNum: '',
        num: '',
        unitPrice: '',
        cost: ''
      }
    },
    // 新增加工费用
    handleAddProcessCost(){
      this.resetProcessCostForm();
      this.titleProcessCost = '新增加工费用';
      this.openProcessCost = true;
    },
    // 修改加工费用
    handleUpdateProcessCost(row){
      this.processCostForm = row;
      this.titleProcessCost = '修改加工费用';
      this.openProcessCost = true;
    },
    // 删除加工费用
    handleDeleteProcessCost(row){
      this.$confirm('是否删除这条加工费用？')
      .then(() => {
         this.loadingProcessCost = true;
         this.processCostTableData.splice(this.processCostTableData.indexOf(row),1)
         setTimeout(() => {
           this.loadingProcessCost = false;
           this.$message.success('删除成功');
         },1000)
      })
    },
    // 加工费用提交
    submitFormProcessCost(){
      this.$refs["processCostForm"].validate((valid) => {
        if (valid) {
          this.loadingProcessCost = true;
          if(this.tabsTable == '订单计划成本'){
            if(this.titleProcessCost == '新增加工费用'){
              setTimeout(() => {
                this.loadingProcessCost = false;
                this.$message.success('新增加工费用成功');
                this.processCostTableData.push(this.processCostForm);
              },1000)
              this.openProcessCost = false;
            } else if(this.titleProcessCost == '修改加工费用'){
              setTimeout(() => {
                this.loadingProcessCost = false;
                this.$message.success('修改加工费用成功');
                this.processCostTableData.map(item,index => {
                  if(item.partCode == this.processCostForm.partCode){
                    this.processCostTableData[index] = this.processCostForm
                  }
                })
              },1000)
              this.openProcessCost = false;
            }
          } else if(this.tabsTable == '订单实际成本'){
            if(this.titleProcessCost == '新增加工费用'){
              setTimeout(() => {
                this.loadingProcessCost = false;
                this.$message.success('新增加工费用成功');
                this.processCostTableData.push(this.processCostForm);
              },1000)
              this.openProcessCost = false;
            } else if(this.titleProcessCost == '修改加工费用'){
              setTimeout(() => {
                this.loadingProcessCost = false;
                this.$message.success('修改加工费用成功');
                this.processCostTableData.map(item,index => {
                  if(item.partCode == this.processCostForm.partCode){
                    this.processCostTableData[index] = this.processCostForm
                  }
                })
              },1000)
              this.openProcessCost = false;
            }
          } 
        }
      })
    },
    // 关闭加工费用
    cancelProcessCost(){
      this.resetProcessCostForm();
      this.openProcessCost = false;
    },
    // 重置加工费用
    resetProcessCostForm() {
      this.processCostForm = {
        partCode: '',
        partName: '',
        specification: '',
        unit: '',
        useNum: '',
        num: '',
        unitPrice: '',
        cost: ''
      }
    },
    // 新增二次加工费用
    handleAddSecondProcessCost(){
      this.resetSecondProcessCostForm();
      this.titleSecondProcessCost = '新增二次加工费用';
      this.openSecondProcessCost = true;
    },
    // 修改二次加工费用
    handleUpdateSecondProcessCost(row){
      this.secondProcessCostForm = row;
      this.titleSecondProcessCost = '修改二次加工费用';
      this.openSecondProcessCost = true;
    },
    // 删除二次加工费用
    handleDeleteSecondProcessCost(row){
      this.$confirm('是否删除这条二次加工费用？')
      .then(() => {
        this.loadingSecondProcessCost = true;
        this.secondProcessCostTableData.splice(this.secondProcessCostTableData.indexOf(row),1)
        setTimeout(() => {
          this.loadingSecondProcessCost = false;
          this.$message.success('删除成功');
        },1000)
      })
    },
    // 二次加工费用提交
    submitFormSecondProcessCost(){
      this.$refs["secondProcessCostForm"].validate((valid) => {
        if (valid) {          
          this.loadingSecondProcessCost = true;
          if(this.tabsTable == '订单计划成本'){          
            if(this.titleSecondProcessCost == '新增二次加工费用'){          
              setTimeout(() => {
                this.loadingSecondProcessCost = false;
                this.$message.success('新增二次加工费用成功');
                this.secondProcessCostTableData.push(this.secondProcessCostForm);
              },1000)
              this.openSecondProcessCost = false;
            } else if(this.titleSecondProcessCost == '修改二次加工费用'){          
              setTimeout(() => {
                this.loadingSecondProcessCost = false;
                this.$message.success('修改二次加工费用成功');
                this.secondProcessCostTableData.map(item,index => {
                  if(item.partCode == this.secondProcessCostForm.partCode){
                    this.secondProcessCostTableData[index] = this.secondProcessCostForm
                  }
                })
              },1000)
              this.openSecondProcessCost = false;
            }
          } else if(this.tabsTable == '订单实际成本'){          
            if(this.titleSecondProcessCost == '新增二次加工费用'){          
              setTimeout(() => {
                this.loadingSecondProcessCost = false;
                this.$message.success('新增二次加工费用成功');
                this.secondProcessCostTableData.push(this.secondProcessCostForm);
              },1000)
              this.openSecondProcessCost = false;
            } else if(this.titleSecondProcessCost == '修改二次加工费用'){          
              setTimeout(() => {
                this.loadingSecondProcessCost = false;
                this.$message.success('修改二次加工费用成功');
                this.secondProcessCostTableData.map(item,index => {
                  if(item.partCode == this.secondProcessCostForm.partCode){
                    this.secondProcessCostTableData[index] = this.secondProcessCostForm
                  }
                })
              },1000)
              this.openSecondProcessCost = false;
            }
          } 
        }
        })
      },
      // 关闭二次加工费用
      cancelSecondProcessCost(){
        this.resetSecondProcessCostForm();
        this.openSecondProcessCost = false;
      },
      // 重置二次加工费用
      resetSecondProcessCostForm() {
        this.secondProcessCostForm = {
          partCode: '',
          partName: '',
          specification: '',
          unit: '',
          useNum: '',
          num: '',
          unitPrice: '',
          cost: ''
        }
      },
  },
}
</script>
